# -*- codeing = utf-8 -*-
# @Time : 2021/2/25 14:50
# @Atuthor: 朱朱
# @File: 089装饰器详解.py
# @Software: PyCharm
import time

def cal_time(fn):
    print('我是外部,我被调用了')
    print(f'{fn}')

    def inner(x,*args,**kwargs):
        start = time.time()
        s = fn(x) # 定义变里s,接收被装饰函数的返回值
        end = time.time()
        return s,end-start # 返回给inner(已经是具体的值了)
    return inner # 将具体的值返回给装饰函数

@cal_time
def demo(n):
    x = 0
    for i in range(1,n):
        x+=i
    return x # 就是s接收的值

m=demo(111111111,'good',y='hello')
# 我是外部,我被调用了
# <function demo at 0x000001C292B775E8>
print('------------------------------------')
print(m)